Skip to content

fix: send one cancel request for concurrent cancel() calls - #604

Closed
vuanhphung wants to merge 1 commit into
mainfrom
fix/dedupe-concurrent-cancel
Closed

vuanhphung wants to merge 1 commit into
mainfrom
fix/dedupe-concurrent-cancel

Conversation

@vuanhphung

Copy link
Copy Markdown
Collaborator

DBSQLOperation.cancel() set cancelled only after the backend cancel resolved (lib/DBSQLOperation.ts:206-213), so concurrent cancel() calls on one operation each sent their own request. On a live warehouse, three concurrent cancel() calls on a running Thrift statement sent three CancelOperation RPCs. databricks-driver-test STATEMENT-022 (Simultaneous Statement Cancellation) requires exactly one on Thrift. The kernel backend already sends a single CancelStatement, because kernelCancel sets its flag before the RPC.

Concurrent calls now share the in-flight cancel request. It is cleared when it settles, so a failed cancel rejects every waiting caller, leaves the operation un-cancelled (as before), and can be retried.

Verification:

  • New unit tests in tests/unit/DBSQLOperation.test.ts: one RPC for three concurrent calls, and a shared failure followed by a successful retry. Both fail without the fix (3 and 2 RPCs). npm test: 1753 passing. npm run lint and prettier are clean.
  • Live, through the driver-test proxy, against this branch: Thrift STATEMENT-022 sends one CancelOperation (it sent three on main), and STATEMENT-015 (single cancel) plus SEA STATEMENT-015/022 still pass.

This pull request and its description were written by Isaac.

DBSQLOperation.cancel() set its cancelled flag only after the backend
cancel resolved, so concurrent calls on one operation each sent their own
request: three cancel() calls produced three Thrift CancelOperation RPCs.
Concurrent calls now share the in-flight request. It is cleared when it
settles, so a failed cancel can still be retried. The kernel backend
already sent a single CancelStatement.

Found by databricks-driver-test STATEMENT-022 (Simultaneous Statement
Cancellation).

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Closing. STATEMENT-022 now accepts one cancel RPC per concurrent cancel() call and only requires that the calls are safe: none throws or hangs, and the statement ends canceled. main already meets that on Thrift and SEA (3 live passthrough runs per backend plus unit probes), so this change would only reduce the Thrift CancelOperation count.

@vuanhphung vuanhphung closed this Nov 15, 2026

This branch was previously deployed

1 inactive deployment
azure-prod — 6d9287b5 Deployed Nov 13, 2026 by vuanhphung via e2e-test (24.22.1, 24_22_1) #1995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant